﻿<template id="@(ViewBag.GetCompTemplate("reset"))">
    <el-dialog v-model="visible" :width="400" :title="title" :destroy-on-close="true" :close-on-click-modal="false" :close-on-press-escape="false" draggable v-on:close="closed">
        <el-divider class="layout-page-form-top-border"></el-divider>
        <el-form ref="formRef" :rules="rules" :disabled="disabled" :model="record" :hide-required-asterisk="disabled" label-width="auto" label-suffix=" :">
            <el-form-item label="用户名" prop="Username">
                <el-input :disabled="true" v-model="record.Username"></el-input>
            </el-form-item>
            <el-form-item label="新密码" prop="Password">
                <el-input v-model="record.Password"></el-input>
            </el-form-item>
        </el-form>
        <template #footer>
            <el-button v-on:click="close">取消</el-button>
            <el-button type="primary" v-on:click="submit">确定</el-button>
        </template>
    </el-dialog>
</template>
<script type="text/javascript">
    var @(ViewBag.GetCompName("reset")) = {
        template: "#@(ViewBag.GetCompTemplate("reset"))", data() {
            return {
                path: "@(ViewBag.PagePath)",
                visible: false,
                title: "用户重置密码",
                rules: {
                    Password: [{ required: true, message: "请填写新密码" }]
                },
                record: {},
                disabled: false
            }
        },
        methods: {
            open(record){
                var that = this;
                that.record = record;
                that.visible = true;
            },
            close(){
                this.visible = false;
            },
            closed(){
                this.record = {};
            },
            submit(){
                var that = this;
                that.$refs.formRef.validate(valid => {
                    if (valid) {
                        app.func.submit(`${that.path}/reset`, that.record, that.close);
                    }
                });
            }
        },
        mounted() { }
    };
</script>